//
//  BLSocket.swift
//  TCPClientDemo
//
//  Created by adel on 2017/9/20.
//  Copyright © 2017年 adel. All rights reserved.
//

import UIKit
import SwiftSocket
class BLSocket: NSObject {

    fileprivate var socket : TCPClient
    
    init(address : String , port : Int32) {
        
      socket = TCPClient(address: address, port: port)
        
        super.init()
    }
    
}


extension BLSocket {
    
     func connectServer() -> Bool{
        
        if socket.connect(timeout: 10).isSuccess {
            
            let message = "你好啊"
            let sendData = message.data(using: .utf8)
            print(sendData!.count)
            let result = socket.send(data: sendData!)
            
            print(result)
            
            return true
        }else{
            
            return false
        }
    }
    
}
